package com.hxrd;

import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.UserInfo;
/**
 * @Description todo
 * @Author Administrator
 * @Date 2019/11/15 9:59
 **/
public class TestSqoop {
    private static final String USER="admin";
    private static final String PASSWORD="ruijie@wuhan01";
    private static final String HOST="223.75.63.163";
    private static final int DEFAULT_SSH_PORT=22;
    public static void main(String[] arg){
        try{
            JSch jsch=new JSch();
            Session session = jsch.getSession(USER,HOST,DEFAULT_SSH_PORT);
            session.setPassword(PASSWORD);

            UserInfo userInfo = new UserInfo() {
                public String getPassphrase() {
                    System.out.println("getPassphrase");
                    return null;
                }
                public String getPassword() {
                    System.out.println("getPassword");
                    return null;
                }
                public boolean promptPassword(String s) {
                    System.out.println("promptPassword:"+s);
                    return false;
                }
                public boolean promptPassphrase(String s) {
                    System.out.println("promptPassphrase:"+s);
                    return false;
                }
                public boolean promptYesNo(String s) {
                    System.out.println("promptYesNo:"+s);
                    return true;//notice here!
                }
                public void showMessage(String s) {
                    System.out.println("showMessage:"+s);
                }
            };
            session.setUserInfo(userInfo);
            session.connect(30000);   // making a connection with timeout.
            Channel channel=session.openChannel("shell");
            channel.setInputStream(System.in);
            channel.setOutputStream(System.out);
            //channel.connect();
            channel.connect(3*1000);
        }
        catch(Exception e){
            System.out.println(e);
        }
    }
}